package com.ajhlp.spring_modules.web.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class AuthenticationController {
	
	@ModelAttribute("username")
	public String getUserName(){
		try {
			return SecurityContextHolder.getContext().getAuthentication().getName();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			return "";
		}
	}

	@RequestMapping({"/","/index"})
    public String toIndex() {
        return "index";
    }
	
	@RequestMapping({"/login"})
    public String toLogin() {
        return "login";
    }
	
	@RequestMapping({"/404"})
    public String toNotFound() {
        return "404";
    }
}
